<% if @src_metrics.empty? %>

	<div id='source-ips-graph' style='display:none;' class='dashboard-graph no-pie-data'></div>
	
<% else %>

	<% content_for :footer do %>

		<script type="text/javascript">

		chart = new Highcharts.Chart({
		      chart: {
		         renderTo: 'source-ips-graph',
		         margin: [50, 165, 50, 160]
		      },
          credits: {
            enabled: false
          },
		      title: {
		         text: ''
		      },
		      tooltip: {
		         formatter: function() {
					return "<b>" + this.point.name.substring(0, 30) + "</b>... (" + this.y + " sessions)"
		         }
		      },
		      plotOptions: {
		         pie: {
             events: {
                click: function(event) {
                  HCloader(event.target.nearestViewportElement.parentElement.id);
                  document.location = baseuri + '/results?title=Source Address '+event.point.name+'&match_all=true&search%5B0%5D%5Bcolumn%5D=source_ip&search'+
                    '%5B0%5D%5Benabled%5D=true&search%5B0%5D%5Boperator%'+
                    '5D=is&search%5B0%5D%5Bvalue%5D='+event.point.name+'&search%'+
                    '5B1%5D%5Bcolumn%5D=start_time&search%5B1%5D%5Benabl'+
                    'ed%5D=true&search%5B1%5D%5Boperator%5D=gte&search%5B'+
                    '1%5D%5Bvalue%5D=<%= @start_time.strftime("%Y-%m-%d %H:%M:%S") %>&search%5B2%5D%5B'+
                    'column%5D=end_time&search%5B2%5D%5Benabled%5D=true&'+
                    'search%5B2%5D%5Boperator%5D=lte&search%5B2%5D%5Bvalu'+
                    'e%5D=<%= @end_time.strftime("%Y-%m-%d %H:%M:%S") %>';
                 },
              },
		            allowPointSelect: true,
		            cursor: 'pointer',
								dataLabels: {
										distance: 20,
									  formatter: function() {
										return "" + this.point.name.substring(0, 30) + "... (" + Math.round(this.percentage) + "%)"
									 },
		                connectorColor: '#888',
										style: {
											fontSize: 10
										}
		            }
		         }
		      },
			    legend: {
			        enabled: false
			    },
		       series: [{
		         type: 'pie',
		         name: 'Unique Source Addresses',
             data: [
              <% @src_metrics.each do |key,value| %>
                 ['<%= key.to_s %>', <%= value %>],
              <% end %>
		         ]
		      }]
		   });

		</script>

	<% end %>

	<div id='source-ips-graph' style='display:none;' class='dashboard-graph'></div>

<% end %>
